//
//  NSDate+String.m
//  DADReadTool
//
//  Created by wanjiading on 15/5/30.
//  Copyright (c) 2015年 DAD. All rights reserved.
//

#import "NSDate+String.h"

@implementation NSDate (String)



@end


@implementation NSString (Date)

/**
 *  字符串转化成日期
 */
- (NSDate *)dateWithString {
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    return [self dateWithStringWithFormat:dateFormat];
}

/**
 *  字符串转化成日期
 */
- (NSDate *)dateWithStringWithFormat:(NSDateFormatter *)dateFormat {
    return [dateFormat dateFromString:self];
}

/**
 *  日期转化成字符串
 */
- (NSString *)stringWithDateString {
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"yyyy-MM-dd"];
    
    return [self stringWithDateStringAndFormat:dateFormat];
}

/**
 *  日期转化成字符串
 */
- (NSString *)stringWithDateStringAndFormat:(NSDateFormatter *)dateFormat {
    NSDate *date = [self dateWithString];
    return [dateFormat stringFromDate:date];
}

@end


